<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<script type="text/javascript">
		// 1.求下面数组的平均值
        var arr1 = [1, 6, 7, 20, 30]
        let sum = 0
        arr1.forEach(function(val, index){
        	sum += val
        })
        console.log(sum / arr1.lenght)
        // 2.找出数组最大值
		var arr2 = [3, 4, 6, 11, 35, 20, 16]
		let max = arr2[0]
		arr2.forEach(function(val,index){
			if (max < val) {
				max = val
			}
		})
		console.log(max)

		// 3.找出数组最大值并放到最后
		var arr3 = [3, 4, 6, 11, 35, 20, 16]
		for(let i = 0; i < arr3.lenght; i++){
			if (arr3[i] > arr3[i + 1]) {
				var temp = arr3[i]
				arr3[i] = arr3[i + 1]
				arr3[i + 1] = temp
			}
		}
		console.log(arr3)

	</script>
</body>
</html>